package com.example.server.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;
import java.util.Objects;

@Mapper
public interface Databasemapper {
    @Select("select count(*) from user where sex= '男'")
    int selectbox();
    @Select("select count(*) from user where sex= '女'")
    int selectgirl();
    @Select("select count(*) from location where type = '山林'")
    int selectmountain();
    @Select("select count(*) from location where type = '海洋'")
    int selectocean();
    @Select("select count(*) from location where type = '城市'")
    int selectcity();
    @Select("select count(*) from location where type = '乡村'")
    int selectcountry();
    @Select("select count(*) from user where Year(created_at) = #{year}")
    int selectregis(int year);
    @Select("select city,count(*) from location group by city")
    List<Map<String, Object>> selectprovince();//这里是map获取数据，但是mybatistic会映射成一个对象组，所有需要嵌套！
    @Select("select city,count(*) as count_as from location group by city order by count_as desc limit 10")
    List<Map<String, Object>> selectprovinceall();
    @Select("select l.city,count(*) as count_as from user_far s,user u,location l where l.place_id = s.location_id and u.uid = s.user_id group by l.city order by count_as desc limit 5")
    List<Map<String, Object>> selectfar();
    @Select("select l.city,count(*) as count_as from user_review s,user u,location l where l.place_id = s.location_id and u.uid = s.user_id group by l.city order by count_as desc limit 5")
    List<Map<String, Object>> selectreview();
}
